home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / OSA.h < prev    next >
Text File  |  1995-07-06  |  56KB  |  1,602 lines

  1. /*
  2.      File:        OSA.h
  3.  
  4.      Contains:    AppleScript Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.1
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __OSA__
  21. #define __OSA__
  22.  
  23.  
  24. #ifndef __ERRORS__
  25. #include <Errors.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __APPLEEVENTS__
  30. #include <AppleEvents.h>
  31. #endif
  32. /*    #include <Types.h>                                            */
  33. /*    #include <Memory.h>                                            */
  34. /*        #include <MixedMode.h>                                    */
  35. /*    #include <OSUtils.h>                                        */
  36. /*    #include <Events.h>                                            */
  37. /*        #include <Quickdraw.h>                                    */
  38. /*            #include <QuickdrawText.h>                            */
  39. /*    #include <EPPC.h>                                            */
  40. /*        #include <AppleTalk.h>                                    */
  41. /*        #include <Files.h>                                        */
  42. /*            #include <Finder.h>                                    */
  43. /*        #include <PPCToolbox.h>                                    */
  44. /*        #include <Processes.h>                                    */
  45. /*    #include <Notification.h>                                    */
  46.  
  47. #ifndef __AEOBJECTS__
  48. #include <AEObjects.h>
  49. #endif
  50.  
  51. #ifndef __COMPONENTS__
  52. #include <Components.h>
  53. #endif
  54.  
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58.  
  59. #if PRAGMA_ALIGN_SUPPORTED
  60. #pragma options align=mac68k
  61. #endif
  62.  
  63. #if PRAGMA_IMPORT_SUPPORTED
  64. #pragma import on
  65. #endif
  66.  
  67.  
  68. enum {
  69.     kOSAComponentType            = 'osa '
  70. };
  71.  
  72. /* 0x73637074 */
  73. enum {
  74.     kOSAGenericScriptingComponentSubtype = 'scpt'
  75. };
  76.  
  77. /*    Type of script document files.    */
  78. /* 0x6f736173 */
  79. enum {
  80.     kOSAFileType                = 'osas'
  81. };
  82.  
  83. /*
  84.         Suite and event code of the RecordedText event. 
  85.         (See OSAStartRecording, below.)
  86.     */
  87. /* 0x61736372 */
  88. enum {
  89.     kOSASuite                    = 'ascr'
  90. };
  91.  
  92. /* 0x72656364 */
  93. enum {
  94.     kOSARecordedText            = 'recd'
  95. };
  96.  
  97. /* Selector returns boolean */
  98. /* 0x6d6f6469 */
  99. enum {
  100.     kOSAScriptIsModified        = 'modi'
  101. };
  102.  
  103. /* Selector returns boolean */
  104. /* 0x63736372 */
  105. enum {
  106.     kOSAScriptIsTypeCompiledScript = 'cscr'
  107. };
  108.  
  109. /* Selector returns boolean */
  110. /* 0x76616c75 */
  111. enum {
  112.     kOSAScriptIsTypeScriptValue    = 'valu'
  113. };
  114.  
  115. /* Selector returns boolean */
  116. /* 0x636e7478 */
  117. enum {
  118.     kOSAScriptIsTypeScriptContext = 'cntx'
  119. };
  120.  
  121. /* Selector returns a DescType which may be passed to OSACoerceToDesc */
  122. /* 0x62657374 */
  123. enum {
  124.     kOSAScriptBestType            = 'best'
  125. };
  126.  
  127. /*
  128.         This selector is used to determine whether a script has source 
  129.         associated with it that when given to OSAGetSource, the call will not
  130.         fail.  The selector returns a boolean.
  131.     */
  132. /* 0x67737263 */
  133. enum {
  134.     kOSACanGetSource            = 'gsrc'
  135. };
  136.  
  137. enum {
  138.     typeOSADialectInfo            = 'difo',                        /*  0x6469666f   */
  139.     keyOSADialectName            = 'dnam',                        /*  0x646e616d   */
  140.     keyOSADialectCode            = 'dcod',                        /*  0x64636f64   */
  141.     keyOSADialectLangCode        = 'dlcd',                        /*  0x646c6364   */
  142.     keyOSADialectScriptCode        = 'dscd'
  143. };
  144.  
  145. typedef ComponentResult OSAError;
  146.  
  147. /* Under the Open Scripting Architecture all error results are longs */
  148. typedef unsigned long OSAID;
  149.  
  150. /*
  151.         OSAIDs allow transparent manipulation of scripts associated with
  152.          various scripting systems.
  153.     */
  154.  
  155. enum {
  156.     kOSANullScript                = (OSAID)0
  157. };
  158.  
  159. /* No -script constant. */
  160. enum {
  161.     kOSANullMode                = 0,                            /* sounds better */
  162.     kOSAModeNull                = 0                                /* tastes consistent */
  163. };
  164.  
  165. /*
  166.         Some routines take flags that control their execution.  This constant
  167.         declares default mode settings are used.
  168.     */
  169. typedef pascal OSErr (*OSACreateAppleEventProcPtr)(AEEventClass theAEEventClass, AEEventID theAEEventID, const AEAddressDesc *target, short returnID, long transactionID, AppleEvent *result, long refCon);
  170.  
  171. #if GENERATINGCFM
  172. typedef UniversalProcPtr OSACreateAppleEventUPP;
  173. #else
  174. typedef OSACreateAppleEventProcPtr OSACreateAppleEventUPP;
  175. #endif
  176.  
  177. enum {
  178.     uppOSACreateAppleEventProcInfo = kPascalStackBased
  179.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  180.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(AEEventClass)))
  181.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AEEventID)))
  182.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(AEAddressDesc*)))
  183.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  184.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
  185.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(AppleEvent*)))
  186.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(long)))
  187. };
  188.  
  189. #if GENERATINGCFM
  190. #define NewOSACreateAppleEventProc(userRoutine)        \
  191.         (OSACreateAppleEventUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSACreateAppleEventProcInfo, GetCurrentArchitecture())
  192. #else
  193. #define NewOSACreateAppleEventProc(userRoutine)        \
  194.         ((OSACreateAppleEventUPP) (userRoutine))
  195. #endif
  196.  
  197. #if GENERATINGCFM
  198. #define CallOSACreateAppleEventProc(userRoutine, theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon)        \
  199.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSACreateAppleEventProcInfo, (theAEEventClass), (theAEEventID), (target), (returnID), (transactionID), (result), (refCon))
  200. #else
  201. #define CallOSACreateAppleEventProc(userRoutine, theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon)        \
  202.         (*(userRoutine))((theAEEventClass), (theAEEventID), (target), (returnID), (transactionID), (result), (refCon))
  203. #endif
  204.  
  205. typedef pascal OSErr (*OSASendProcPtr)(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks, AEIdleUPP idleProc, AEFilterUPP filterProc, long refCon);
  206.  
  207. #if GENERATINGCFM
  208. typedef UniversalProcPtr OSASendUPP;
  209. #else
  210. typedef OSASendProcPtr OSASendUPP;
  211. #endif
  212.  
  213. enum {
  214.     uppOSASendProcInfo = kPascalStackBased
  215.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  216.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(AppleEvent*)))
  217.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AppleEvent*)))
  218.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(AESendMode)))
  219.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(AESendPriority)))
  220.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
  221.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(AEIdleUPP)))
  222.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(AEFilterUPP)))
  223.          | STACK_ROUTINE_PARAMETER(8, SIZE_CODE(sizeof(long)))
  224. };
  225.  
  226. #if GENERATINGCFM
  227. #define NewOSASendProc(userRoutine)        \
  228.         (OSASendUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSASendProcInfo, GetCurrentArchitecture())
  229. #else
  230. #define NewOSASendProc(userRoutine)        \
  231.         ((OSASendUPP) (userRoutine))
  232. #endif
  233.  
  234. #if GENERATINGCFM
  235. #define CallOSASendProc(userRoutine, theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon)        \
  236.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSASendProcInfo, (theAppleEvent), (reply), (sendMode), (sendPriority), (timeOutInTicks), (idleProc), (filterProc), (refCon))
  237. #else
  238. #define CallOSASendProc(userRoutine, theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon)        \
  239.         (*(userRoutine))((theAppleEvent), (reply), (sendMode), (sendPriority), (timeOutInTicks), (idleProc), (filterProc), (refCon))
  240. #endif
  241.  
  242. /**************************************************************************
  243.     Standard Script Errors
  244. **************************************************************************
  245.     It is recommended that scripting components use the following set of error
  246.     codes to signal failure when applicable.  This enables applications that
  247.     use the OSA API to deal with some class of script errors in a less than 
  248.     ad hoc manner.  Scripting components are of course encouraged to return
  249.     component-specific errors when these don't apply.
  250. **************************************************************************/
  251. /*        Dynamic errors:
  252.  
  253.     These errors result from data-dependent conditions and are typically
  254.     signaled at runtime.
  255. */
  256. /*
  257.         Signaled when a value can't be coerced to the desired type. Similar
  258.           to errOSATypeError except results from coercion.
  259.     */
  260. enum {
  261.     errOSACantCoerce            = errAECoercionFail
  262. };
  263.  
  264. /* Signaled when an object is not found in a container */
  265. enum {
  266.     errOSACantAccess            = errAENoSuchObject
  267. };
  268.  
  269. /*
  270.         Signaled when an object cannot be set in a container.  Same as 
  271.           AERegistry error errAEWriteDenied.
  272.     */
  273. enum {
  274.     errOSACantAssign            = -10006
  275. };
  276.  
  277. /*
  278.         Signaled by user scripts or applications when no actual error code
  279.           is to be returned.  Simply means "an error has occurred".  Most useful
  280.           in conjunction with an error message from the application.
  281.     */
  282. enum {
  283.     errOSAGeneralError            = -2700
  284. };
  285.  
  286. /* Signaled when there is an attempt to divide by zero */
  287. enum {
  288.     errOSADivideByZero            = -2701
  289. };
  290.  
  291. /* Signaled when integer or real value is too large to be represented */
  292. enum {
  293.     errOSANumericOverflow        = -2702
  294. };
  295.  
  296. /*
  297.         Signaled when application can't be launched or when it is remote and
  298.           program linking is not enabled.
  299.     */
  300. enum {
  301.     errOSACantLaunch            = -2703
  302. };
  303.  
  304. /* Signaled when an application can't respond to AppleEvents */
  305. enum {
  306.     errOSAAppNotHighLevelEventAware = -2704
  307. };
  308.  
  309. /* Signaled when an application's terminology resource is not readable */
  310. enum {
  311.     errOSACorruptTerminology    = -2705
  312. };
  313.  
  314. /* Signaled when the runtime stack overflows */
  315. enum {
  316.     errOSAStackOverflow            = -2706
  317. };
  318.  
  319. /* Signaled when a runtime internal data structure overflows */
  320. enum {
  321.     errOSAInternalTableOverflow    = -2707
  322. };
  323.  
  324. /*
  325.         Signaled when an intrinsic limitation is exceeded for the size of 
  326.           a value or data structure.
  327.     */
  328. enum {
  329.     errOSADataBlockTooLarge        = -2708
  330. };
  331.  
  332. enum {
  333.     errOSACantGetTerminology    = -2709
  334. };
  335.  
  336. enum {
  337.     errOSACantCreate            = -2710
  338. };
  339.  
  340. /*        Component-specific dynamic script errors:
  341.  
  342.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  343.     (Note that error codes from different scripting components in this range will
  344.     overlap.)
  345. */
  346. /*        Static errors:
  347.  
  348.     These errors comprise what are commonly thought of as parse and compile-
  349.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  350.     of these may also occur at runtime.
  351. */
  352. /* Signaled when data was not the right type and coercion is not allowed */
  353. enum {
  354.     errOSATypeError                = errAEWrongDataType
  355. };
  356.  
  357. /* Signaled when a message was sent to an object that didn't handle it */
  358. enum {
  359.     OSAMessageNotUnderstood        = errAEEventNotHandled
  360. };
  361.  
  362. /*
  363.         Signaled when a function to be returned doesn't exist.  (Probably only
  364.           useful in languages with first-class functions that distinguish between
  365.           functions and other values (two name spaces). This is different from
  366.           errOSAMessageNotUnderstood, which may be signaled when the method is
  367.           invoked.
  368.     */
  369. enum {
  370.     OSAUndefinedHandler            = errAEHandlerNotFound
  371. };
  372.  
  373. /* Signaled when a container can never have the requested object */
  374. enum {
  375.     OSAIllegalAccess            = errAEAccessorNotFound
  376. };
  377.  
  378. /* Signaled when index was out of range. Specialization of errOSACantAccess. */
  379. enum {
  380.     OSAIllegalIndex                = errAEIllegalIndex
  381. };
  382.  
  383. /* Signaled when a range is screwy. Specialization of errOSACantAccess. */
  384. enum {
  385.     OSAIllegalRange                = errAEImpossibleRange
  386. };
  387.  
  388. /*
  389.         Signaled when an object can never be set in a container.  Same as 
  390.           AERegistry error errAENotModifiable.
  391.     */
  392. enum {
  393.     OSAIllegalAssign            = -10003
  394. };
  395.  
  396. /*
  397.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  398.          "<this> can't go after <that>").
  399.     */
  400. enum {
  401.     OSASyntaxError                = -2740
  402. };
  403.  
  404. /*
  405.         Signaled when another form of syntax was expected. (e.g. "expected
  406.           a <type> but found <this>").
  407.     */
  408. enum {
  409.     OSASyntaxTypeError            = -2741
  410. };
  411.  
  412. /* Signaled when a name or number is too long to be parsed */
  413. enum {
  414.     OSATokenTooLong                = -2742
  415. };
  416.  
  417. /*
  418.         Signaled when a parameter is missing for a function invocation.  Note
  419.           that in some languages, this error may occur at runtime.
  420.     */
  421. enum {
  422.     OSAMissingParameter            = errAEDescNotFound
  423. };
  424.  
  425. /*
  426.         Signaled when function is called with the wrong number of parameters,
  427.           or a parameter pattern cannot be matched.
  428.     */
  429. enum {
  430.     OSAParameterMismatch        = errAEWrongNumberArgs
  431. };
  432.  
  433. /*
  434.         Signaled when a formal parameter, local variable, or instance variable
  435.           is specified more than once.
  436.     */
  437. enum {
  438.     OSADuplicateParameter        = -2750
  439. };
  440.  
  441. /*
  442.         Signaled when a formal parameter, local variable, or instance variable
  443.           is specified more than once.
  444.     */
  445. enum {
  446.     OSADuplicateProperty        = -2751
  447. };
  448.  
  449. /*
  450.         Signaled when more than one handler is defined with the same name in 
  451.           a scope where the language doesn't allow it.
  452.     */
  453. enum {
  454.     OSADuplicateHandler            = -2752
  455. };
  456.  
  457. /* Signaled when a variable is accessed that has no value */
  458. enum {
  459.     OSAUndefinedVariable        = -2753
  460. };
  461.  
  462. /*
  463.         Signaled when a variable is declared inconsistently in the same scope,
  464.           such as both local and global.
  465.     */
  466. enum {
  467.     OSAInconsistentDeclarations    = -2754
  468. };
  469.  
  470. /*
  471.         Signaled when illegal control flow occurs in an application (no catcher
  472.           for throw, non-lexical loop exit, etc.).
  473.     */
  474. enum {
  475.     OSAControlFlowError            = -2755
  476. };
  477.  
  478. /*        Component-specific static script errors:
  479.  
  480.     The range -2760 thru -2779 is reserved for component-specific parsing and
  481.     compile-time errors. (Note that error codes from different scripting
  482.     components in this range will overlap.)
  483. */
  484. /*        Dialect-specific script errors:
  485.  
  486.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  487.     scripting components that support dialects. (Note that error codes from
  488.     different scripting components in this range will overlap, as well as error
  489.     codes from different dialects in the same scripting component.)
  490. */
  491. /**************************************************************************
  492.     OSA Interface Descriptions
  493. **************************************************************************
  494.     The OSA Interface is broken down into a required interface, and several
  495.     optional interfaces to support additional functionality.  A given scripting
  496.     component may choose to support only some of the optional interfaces in
  497.     addition to the basic interface.  The OSA Component Flags may be used to 
  498.     query the Component Manager to find a scripting component with a particular
  499.     capability, or determine if a particular scripting component supports a 
  500.     particular capability.
  501. **************************************************************************/
  502. /* OSA Component Flags: */
  503. enum {
  504.     kOSASupportsCompiling        = 0x0002,
  505.     kOSASupportsGetSource        = 0x0004,
  506.     kOSASupportsAECoercion        = 0x0008,
  507.     kOSASupportsAESending        = 0x0010,
  508.     kOSASupportsRecording        = 0x0020,
  509.     kOSASupportsConvenience        = 0x0040,
  510.     kOSASupportsDialects        = 0x0080,
  511.     kOSASupportsEventHandling    = 0x0100
  512. };
  513.  
  514. /* Component Selectors: */
  515. enum {
  516.     kOSASelectLoad                = 0x0001,
  517.     kOSASelectStore                = 0x0002,
  518.     kOSASelectExecute            = 0x0003,
  519.     kOSASelectDisplay            = 0x0004,
  520.     kOSASelectScriptError        = 0x0005,
  521.     kOSASelectDispose            = 0x0006,
  522.     kOSASelectSetScriptInfo        = 0x0007,
  523.     kOSASelectGetScriptInfo        = 0x0008,
  524.     kOSASelectSetActiveProc        = 0x0009,
  525.     kOSASelectGetActiveProc        = 0x000A
  526. };
  527.  
  528. /* Compiling: */
  529. enum {
  530.     kOSASelectScriptingComponentName = 0x0102,
  531.     kOSASelectCompile            = 0x0103,
  532.     kOSASelectCopyID            = 0x0104
  533. };
  534.  
  535. /* GetSource: */
  536. enum {
  537.     kOSASelectGetSource            = 0x0201
  538. };
  539.  
  540. /* AECoercion: */
  541. enum {
  542.     kOSASelectCoerceFromDesc    = 0x0301,
  543.     kOSASelectCoerceToDesc        = 0x0302
  544. };
  545.  
  546. /* AESending: */
  547. enum {
  548.     kOSASelectSetSendProc        = 0x0401,
  549.     kOSASelectGetSendProc        = 0x0402,
  550.     kOSASelectSetCreateProc        = 0x0403,
  551.     kOSASelectGetCreateProc        = 0x0404,
  552.     kOSASelectSetDefaultTarget    = 0x0405
  553. };
  554.  
  555. /* Recording: */
  556. enum {
  557.     kOSASelectStartRecording    = 0x0501,
  558.     kOSASelectStopRecording        = 0x0502
  559. };
  560.  
  561. /* Convenience: */
  562. enum {
  563.     kOSASelectLoadExecute        = 0x0601,
  564.     kOSASelectCompileExecute    = 0x0602,
  565.     kOSASelectDoScript            = 0x0603
  566. };
  567.  
  568. /* Dialects: */
  569. enum {
  570.     kOSASelectSetCurrentDialect    = 0x0701,
  571.     kOSASelectGetCurrentDialect    = 0x0702,
  572.     kOSASelectAvailableDialects    = 0x0703,
  573.     kOSASelectGetDialectInfo    = 0x0704,
  574.     kOSASelectAvailableDialectCodeList = 0x0705
  575. };
  576.  
  577. /* Event Handling: */
  578. enum {
  579.     kOSASelectSetResumeDispatchProc = 0x0801,
  580.     kOSASelectGetResumeDispatchProc = 0x0802,
  581.     kOSASelectExecuteEvent        = 0x0803,
  582.     kOSASelectDoEvent            = 0x0804,
  583.     kOSASelectMakeContext        = 0x0805
  584. };
  585.  
  586. /* scripting component specific selectors are added beginning with this value  */
  587. enum {
  588.     kOSASelectComponentSpecificStart = 0x1001
  589. };
  590.  
  591. /*        Mode Flags:
  592.  
  593.     Warning: These should not conflict with the AESend mode flags in
  594.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  595. */
  596. /*
  597.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  598.           instruct the scripting component to not retain the "source" of an
  599.           expression.  This will cause the OSAGetSource call to return the error
  600.           errOSASourceNotAvailable if used.  However, some scripting components
  601.           may not retain the source anyway.  This is mainly used when either space
  602.           efficiency is desired, or a script is to be "locked" so that its
  603.           implementation may not be viewed.
  604.     */
  605. enum {
  606.     kOSAModePreventGetSource    = 0x00000001
  607. };
  608.  
  609. /*
  610.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  611.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  612.           indicate whether or not the script may interact with the user, switch
  613.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  614.           corresponding AESend mode supplied.
  615.     */
  616. enum {
  617.     kOSAModeNeverInteract        = kAENeverInteract,
  618.     kOSAModeCanInteract            = kAECanInteract,
  619.     kOSAModeAlwaysInteract        = kAEAlwaysInteract,
  620.     kOSAModeDontReconnect        = kAEDontReconnect
  621. };
  622.  
  623. /*
  624.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  625.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  626.           indicate whether or not AppleEvents should be sent with the
  627.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  628.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  629.           provide a more convenient default, i.e. not supplying any mode
  630.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  631.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  632.           without kAECanSwitchLayer.
  633.     */
  634. enum {
  635.     kOSAModeCantSwitchLayer        = 0x00000040
  636. };
  637.  
  638. /*
  639.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  640.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  641.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  642.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  643.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  644.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  645.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  646.           cause AESend to be called without kAEDontRecord.
  647.     */
  648. enum {
  649.     kOSAModeDoRecord            = 0x00001000
  650. };
  651.  
  652. /*
  653.         This is a mode flag for OSACompile that indicates that a context should
  654.           be created as the result of compilation. All handler definitions are
  655.           inserted into the new context, and variables are initialized by
  656.           evaluating their initial values in a null context (i.e. they must be
  657.           constant expressions).
  658.     */
  659. enum {
  660.     kOSAModeCompileIntoContext    = 0x00000002
  661. };
  662.  
  663. /*
  664.         This is a mode flag for OSACompile that indicates that the previous
  665.           script ID (input to OSACompile) should be augmented with any new
  666.           definitions in the sourceData rather than replaced with a new script.
  667.           This means that the previous script ID must designate a context.
  668.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  669.           to be implicitly used, causing any new definitions to be initialized
  670.           in a null context.
  671.     */
  672. enum {
  673.     kOSAModeAugmentContext        = 0x00000004
  674. };
  675.  
  676. /*
  677.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  678.           that output only need be human-readable, not re-compilable by OSACompile.
  679.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  680.           off of string values, long lists may have elipses, etc.
  681.     */
  682. enum {
  683.     kOSAModeDisplayForHumans    = 0x00000008
  684. };
  685.  
  686. /*
  687.         This mode flag may be passed to OSAStore in the case where the scriptID
  688.           is a context.  This causes the context to be saved, but not the context's
  689.           parent context.  When the stored context is loaded back in, the parent
  690.           will be kOSANullScript.
  691.     */
  692. enum {
  693.     kOSAModeDontStoreParent        = 0x00010000
  694. };
  695.  
  696. /*
  697.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  698.           be dispatched to the direct object of the event. The direct object (or
  699.           subject attribute if the direct object is a non-object specifier) will
  700.           be resolved, and the resulting script object will be the recipient of
  701.           the message. The context argument to OSAExecuteEvent will serve as the
  702.           root of the lookup/resolution process.
  703.     */
  704. enum {
  705.     kOSAModeDispatchToDirectObject = 0x00020000
  706. };
  707.  
  708. /*
  709.         This mode flag may be passed to OSAExecuteEvent to indicate that
  710.           components do not have to get the data of object specifier arguments.
  711.     */
  712. enum {
  713.     kOSAModeDontGetDataForArguments = 0x00040000
  714. };
  715.  
  716. /**************************************************************************
  717.     OSA Basic Scripting Interface
  718. **************************************************************************
  719.     Scripting components must at least support the Basic Scripting interface.
  720. **************************************************************************/
  721. /*        Loading and Storing Scripts:
  722.  
  723.     These routines allow scripts to be loaded and stored in their internal
  724.     (possibly compiled, non-text) representation.
  725. */
  726. /* Resource type for scripts */
  727. enum {
  728.     kOSAScriptResourceType        = kOSAGenericScriptingComponentSubtype
  729. };
  730.  
  731. /*
  732.         Default type given to OSAStore which creates "generic" loadable script
  733.           data descriptors.
  734.     */
  735. enum {
  736.     typeOSAGenericStorage        = kOSAScriptResourceType
  737. };
  738.  
  739. extern pascal OSAError OSALoad(ComponentInstance scriptingComponent, const AEDesc *scriptData, long modeFlags, OSAID *resultingScriptID)
  740.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0001, 0x7000, 0xA82A);
  741. /*
  742.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  743.     
  744.         Errors:
  745.             badComponentInstance        invalid scripting component instance
  746.             errOSASystemError
  747.             errOSABadStorageType:        scriptData not for this scripting component
  748.             errOSACorruptData:            data seems to be corrupt
  749.             errOSADataFormatObsolete    script data format is no longer supported
  750.             errOSADataFormatTooNew        script data format is from a newer version
  751.         
  752.         ModeFlags:
  753.             kOSAModePreventGetSource
  754.     */
  755. extern pascal OSAError OSAStore(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, long modeFlags, AEDesc *resultingScriptData)
  756.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0002, 0x7000, 0xA82A);
  757. /*
  758.         OSAComponentFunctionInline(kOSASelectStore, 16);
  759.     
  760.         Errors:
  761.             badComponentInstance    invalid scripting component instance
  762.             errOSASystemError
  763.             errOSAInvalidID
  764.             errOSABadStorageType:    desiredType not for this scripting component
  765.         
  766.         ModeFlags:
  767.             kOSAModePreventGetSource
  768.             kOSAModeDontStoreParent
  769.     */
  770. /* Executing Scripts: */
  771. extern pascal OSAError OSAExecute(ComponentInstance scriptingComponent, OSAID compiledScriptID, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  772.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0003, 0x7000, 0xA82A);
  773. /*
  774.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  775.         This call runs a script.  The contextID represents the environment
  776.         with which global variables in the script are resolved.  The constant
  777.         kOSANullScript may be used for the contextID if the application wishes
  778.         to not deal with context directly (a default one is associated with each
  779.         scripting component instance).  The resultingScriptValueID is the 
  780.         result of evaluation, and contains a value which may be displayed using
  781.         the OSAGetSource call.  The modeFlags convey scripting component
  782.         specific information.
  783.     
  784.         Errors:
  785.             badComponentInstance    invalid scripting component instance
  786.             errOSASystemError
  787.             errOSAInvalidID
  788.             errOSAScriptError:        the executing script got an error
  789.     
  790.         ModeFlags:
  791.             kOSAModeNeverInteract
  792.             kOSAModeCanInteract
  793.             kOSAModeAlwaysInteract
  794.             kOSAModeCantSwitchLayer
  795.             kOSAModeDontReconnect
  796.             kOSAModeDoRecord
  797.     */
  798. /* Displaying results: */
  799. extern pascal OSAError OSADisplay(ComponentInstance scriptingComponent, OSAID scriptValueID, DescType desiredType, long modeFlags, AEDesc *resultingText)
  800.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0004, 0x7000, 0xA82A);
  801. /*
  802.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  803.         This call is used to convert results (script value IDs) into displayable
  804.         text. The desiredType should be at least typeChar, and modeFlags are
  805.         scripting system specific flags to control the formatting of the
  806.         resulting text. This call differs from OSAGetSource in that (1) it
  807.         always produces at least typeChar, (2) is only works on script values,
  808.         (3) it may display it's output in non-compilable form (e.g. without
  809.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  810.         (4) it is required by the basic scripting interface.
  811.     
  812.         Errors:
  813.             badComponentInstance    invalid scripting component instance
  814.             errOSASystemError
  815.             errOSAInvalidID
  816.             errAECoercionFail:        desiredType not supported by scripting component
  817.     
  818.         ModeFlags:
  819.             kOSAModeDisplayForHumans
  820.     */
  821. /* Getting Error Information: */
  822. extern pascal OSAError OSAScriptError(ComponentInstance scriptingComponent, OSType selector, DescType desiredType, AEDesc *resultingErrorDescription)
  823.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0005, 0x7000, 0xA82A);
  824. /*
  825.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  826.         Whenever script execution returns errOSAExecutionError, this routine
  827.         may be used to get information about that error.  The selector describes
  828.         the type of information desired about the error (various selectors are
  829.         listed below).  The desiredType indicates the data type of the result
  830.         desired for that selector.
  831.     
  832.         Errors:
  833.             badComponentInstance    invalid scripting component instance
  834.             errOSASystemError
  835.             errOSABadSelector:        selector not supported by scripting component
  836.             errAECoercionFail:        desiredType not supported by scripting component
  837.     */
  838. /* OSAScriptError selectors: */
  839. /*
  840.         This selector is used to determine the error number of a script error.
  841.         These error numbers may be either system error numbers, or error numbers
  842.         that are scripting component specific.
  843.         Required desiredTypes:    
  844.               typeShortInteger
  845.     */
  846.  
  847. enum {
  848.     kOSAErrorNumber                = keyErrorNumber
  849. };
  850.  
  851. /*
  852.         This selector is used to determine the full error message associated
  853.         with the error number.  It should include the name of the application
  854.         which caused the error, as well as the specific error that occurred.
  855.         This selector is sufficient for simple error reporting (but see
  856.         kOSAErrorBriefMessage, below).
  857.         Required desiredTypes:
  858.             typeChar                    error message string
  859.     */
  860. enum {
  861.     kOSAErrorMessage            = keyErrorString
  862. };
  863.  
  864. /*
  865.         This selector is used to determine a brief error message associated with
  866.         the error number.  This message and should not mention the name of the
  867.         application which caused the error, any partial results or offending
  868.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  869.         kOSAErrorOffendingObject, below).
  870.         Required desiredTypes:
  871.               typeChar                    brief error message string
  872.     */
  873. /*  0x65727262  */
  874. enum {
  875.     kOSAErrorBriefMessage        = 'errb'
  876. };
  877.  
  878. /*
  879.         This selector is used to determine which application actually got the
  880.         error (if it was the result of an AESend), or the current application
  881.         if ....
  882.         Required desiredTypes:
  883.               typeProcessSerialNumber        PSN of the errant application
  884.               typeChar                    name of the errant application
  885.     */
  886. /*  0x65726170  */
  887. enum {
  888.     kOSAErrorApp                = 'erap'
  889. };
  890.  
  891. /*
  892.         This selector is used to determine any partial result returned by an 
  893.         operation. If an AESend call failed, but a partial result was returned,
  894.         then the partial result may be returned as an AEDesc.
  895.         Required desiredTypes:
  896.               typeBest                    AEDesc of any partial result
  897.     */
  898. /*  0x70746c72   */
  899. enum {
  900.     kOSAErrorPartialResult        = 'ptlr'
  901. };
  902.  
  903. /*
  904.         This selector is used to determine any object which caused the error
  905.         that may have been indicated by an application.  The result is an 
  906.         AEDesc.
  907.         Required desiredTypes:
  908.               typeBest                    AEDesc of any offending object
  909.     */
  910. /*  0x65726f62   */
  911. enum {
  912.     kOSAErrorOffendingObject    = 'erob'
  913. };
  914.  
  915. /*
  916.         This selector is used to determine the type expected by a coercion 
  917.         operation if a type error occurred.
  918.     */
  919. /*  0x65727274   */
  920. enum {
  921.     kOSAErrorExpectedType        = 'errt'
  922. };
  923.  
  924. /*
  925.         This selector is used to determine the source text range (start and 
  926.         end positions) of where the error occurred.
  927.         Required desiredTypes:
  928.               typeOSAErrorRange
  929.     */
  930. /*  0x65726e67  */
  931. enum {
  932.     kOSAErrorRange                = 'erng'
  933. };
  934.  
  935. /*
  936.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  937.         of type short.
  938.     */
  939. /*  0x65726e67   */
  940. enum {
  941.     typeOSAErrorRange            = 'erng'
  942. };
  943.  
  944. /* Field of a typeOSAErrorRange record of typeShortInteger */
  945. /*  0x73726373    */
  946. enum {
  947.     keyOSASourceStart            = 'srcs'
  948. };
  949.  
  950. /* Field of a typeOSAErrorRange record of typeShortInteger */
  951. /*  0x73726365   */
  952. enum {
  953.     keyOSASourceEnd                = 'srce'
  954. };
  955.  
  956. /* Disposing Script IDs: */
  957. extern pascal OSAError OSADispose(ComponentInstance scriptingComponent, OSAID scriptID)
  958.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0006, 0x7000, 0xA82A);
  959. /*
  960.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  961.         Disposes a script or context.
  962.     
  963.         Errors:
  964.             badComponentInstance    invalid scripting component instance
  965.             errOSASystemError
  966.             errOSAInvalidID
  967.     */
  968. /* Getting and Setting Script Information: */
  969. extern pascal OSAError OSASetScriptInfo(ComponentInstance scriptingComponent, OSAID scriptID, OSType selector, long value)
  970.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0007, 0x7000, 0xA82A);
  971. /*
  972.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  973.     
  974.         Errors:
  975.             badComponentInstance    invalid scripting component instance
  976.             errOSASystemError
  977.             errOSAInvalidID
  978.             errOSABadSelector:        selector not supported by scripting component
  979.                                     or selector not for this scriptID
  980.     */
  981. extern pascal OSAError OSAGetScriptInfo(ComponentInstance scriptingComponent, OSAID scriptID, OSType selector, long *result)
  982.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0008, 0x7000, 0xA82A);
  983. /*
  984.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  985.     
  986.         Errors:
  987.             badComponentInstance    invalid scripting component instance
  988.             errOSASystemError
  989.             errOSAInvalidID
  990.             errOSABadSelector:        selector not supported by scripting component
  991.                                     or selector not for this scriptID
  992.     */
  993. /* Manipulating the ActiveProc:
  994.  
  995.     Scripting systems will supply default values for these procedures if they
  996.     are not set by the client:
  997. */
  998. typedef pascal OSErr (*OSAActiveProcPtr)(long refCon);
  999.  
  1000. #if GENERATINGCFM
  1001. typedef UniversalProcPtr OSAActiveUPP;
  1002. #else
  1003. typedef OSAActiveProcPtr OSAActiveUPP;
  1004. #endif
  1005.  
  1006. enum {
  1007.     uppOSAActiveProcInfo = kPascalStackBased
  1008.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  1009.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  1010. };
  1011.  
  1012. #if GENERATINGCFM
  1013. #define NewOSAActiveProc(userRoutine)        \
  1014.         (OSAActiveUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSAActiveProcInfo, GetCurrentArchitecture())
  1015. #else
  1016. #define NewOSAActiveProc(userRoutine)        \
  1017.         ((OSAActiveUPP) (userRoutine))
  1018. #endif
  1019.  
  1020. #if GENERATINGCFM
  1021. #define CallOSAActiveProc(userRoutine, refCon)        \
  1022.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSAActiveProcInfo, (refCon))
  1023. #else
  1024. #define CallOSAActiveProc(userRoutine, refCon)        \
  1025.         (*(userRoutine))((refCon))
  1026. #endif
  1027.  
  1028. extern pascal OSAError OSASetActiveProc(ComponentInstance scriptingComponent, OSAActiveUPP activeProc, long refCon)
  1029.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0009, 0x7000, 0xA82A);
  1030. /*
  1031.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  1032.         If activeProc is nil, the default activeProc is used.
  1033.     
  1034.         Errors:
  1035.             badComponentInstance    invalid scripting component instance
  1036.             errOSASystemError
  1037.     */
  1038. extern pascal OSAError OSAGetActiveProc(ComponentInstance scriptingComponent, OSAActiveUPP *activeProc, long *refCon)
  1039.  FIVEWORDINLINE(0x2F3C, 0x8, 0x000A, 0x7000, 0xA82A);
  1040. /*
  1041.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  1042.     
  1043.         Errors:
  1044.             badComponentInstance    invalid scripting component instance
  1045.             errOSASystemError
  1046.     */
  1047. /**************************************************************************
  1048.     OSA Optional Compiling Interface
  1049. **************************************************************************
  1050.     Scripting components that support the Compiling interface have the 
  1051.     kOSASupportsCompiling bit set in it's ComponentDescription.
  1052. **************************************************************************/
  1053. extern pascal OSAError OSAScriptingComponentName(ComponentInstance scriptingComponent, AEDesc *resultingScriptingComponentName)
  1054.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0102, 0x7000, 0xA82A);
  1055. /*
  1056.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  1057.         Given a scripting component, this routine returns the name of that
  1058.         scripting component in a type that is coercable to text (typeChar).
  1059.         The generic scripting component returns the name of the default
  1060.         scripting component.  This name should be sufficient to convey to the
  1061.         user the kind of script (syntax) he is expected to write.
  1062.     
  1063.         Errors:
  1064.             badComponentInstance    invalid scripting component instance
  1065.             errOSASystemError
  1066.     */
  1067. extern pascal OSAError OSACompile(ComponentInstance scriptingComponent, const AEDesc *sourceData, long modeFlags, OSAID *previousAndResultingScriptID)
  1068.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0103, 0x7000, 0xA82A);
  1069. /*
  1070.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  1071.         Coerces input desc (possibly text) into a script's internal format.
  1072.         Once compiled, the script is ready to run.  The modeFlags convey
  1073.         scripting component specific information.  The previous script ID
  1074.         (result parameter) is made to refer to the newly compiled script,
  1075.         unless it was originally kOSANullScript.  In this case a new script
  1076.         ID is created and used.
  1077.     
  1078.         Errors:
  1079.             badComponentInstance    invalid scripting component instance
  1080.             errOSASystemError
  1081.             errAECoercionFail:        sourceData is not compilable
  1082.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1083.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1084.                                     valid on input
  1085.     
  1086.         ModeFlags:
  1087.             kOSAModePreventGetSource
  1088.             kOSAModeCompileIntoContext
  1089.             kOSAModeAugmentContext
  1090.             kOSAModeNeverInteract
  1091.             kOSAModeCanInteract
  1092.             kOSAModeAlwaysInteract
  1093.             kOSAModeCantSwitchLayer
  1094.             kOSAModeDontReconnect
  1095.             kOSAModeDoRecord
  1096.     */
  1097. extern pascal OSAError OSACopyID(ComponentInstance scriptingComponent, OSAID fromID, OSAID *toID)
  1098.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0104, 0x7000, 0xA82A);
  1099. /*
  1100.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  1101.         If toID is a reference to kOSANullScript then it is updated to have a
  1102.         new scriptID value.  This call can be used to perform undo or revert
  1103.         operations on scripts. 
  1104.     
  1105.         Errors:
  1106.             badComponentInstance    invalid scripting component instance
  1107.             errOSASystemError
  1108.             errOSAInvalidID
  1109.     */
  1110. /**************************************************************************
  1111.     OSA Optional GetSource Interface
  1112. **************************************************************************
  1113.     Scripting components that support the GetSource interface have the 
  1114.     kOSASupportsGetSource bit set in it's ComponentDescription.
  1115. **************************************************************************/
  1116. extern pascal OSAError OSAGetSource(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, AEDesc *resultingSourceData)
  1117.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0201, 0x7000, 0xA82A);
  1118. /*
  1119.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  1120.         This routine causes a compiled script to be output in a form (possibly
  1121.         text) such that it is suitable to be passed back to OSACompile.
  1122.  
  1123.         Errors:
  1124.             badComponentInstance    invalid scripting component instance
  1125.             errOSASystemError
  1126.             errOSAInvalidID
  1127.             errOSASourceNotAvailable    can't get source for this scriptID
  1128.     */
  1129. /**************************************************************************
  1130.     OSA Optional AECoercion Interface
  1131. **************************************************************************
  1132.     Scripting components that support the AECoercion interface have the 
  1133.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  1134. **************************************************************************/
  1135. extern pascal OSAError OSACoerceFromDesc(ComponentInstance scriptingComponent, const AEDesc *scriptData, long modeFlags, OSAID *resultingScriptID)
  1136.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0301, 0x7000, 0xA82A);
  1137. /*
  1138.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  1139.         This routine causes script data to be coerced into a script value.
  1140.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  1141.         compiled script ID (mode flags for OSACompile may be used in this case).
  1142.         Other scriptData descriptors create script value IDs.
  1143.     
  1144.         Errors:
  1145.             badComponentInstance    invalid scripting component instance
  1146.             errOSASystemError
  1147.     
  1148.         ModeFlags:
  1149.             kOSAModePreventGetSource
  1150.             kOSAModeCompileIntoContext
  1151.             kOSAModeNeverInteract
  1152.             kOSAModeCanInteract
  1153.             kOSAModeAlwaysInteract
  1154.             kOSAModeCantSwitchLayer
  1155.             kOSAModeDontReconnect
  1156.             kOSAModeDoRecord
  1157.     */
  1158. extern pascal OSAError OSACoerceToDesc(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, long modeFlags, AEDesc *result)
  1159.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0302, 0x7000, 0xA82A);
  1160. /*
  1161.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  1162.         This routine causes a script value to be coerced into any desired form.
  1163.         If the scriptID denotes a compiled script, then it may be coerced to 
  1164.         typeAppleEvent.
  1165.     
  1166.         Errors:
  1167.             badComponentInstance    invalid scripting component instance
  1168.             errOSASystemError
  1169.             errOSAInvalidID
  1170.     */
  1171. /**************************************************************************
  1172.     OSA Optional AESending Interface
  1173. **************************************************************************
  1174.     Scripting components that support the AESending interface have the 
  1175.     kOSASupportsAESending bit set in it's ComponentDescription.
  1176. **************************************************************************/
  1177. /*
  1178.     Scripting systems will supply default values for these procedures if they
  1179.     are not set by the client:
  1180. */
  1181. extern pascal OSAError OSASetSendProc(ComponentInstance scriptingComponent, OSASendUPP sendProc, long refCon)
  1182.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0401, 0x7000, 0xA82A);
  1183. /*
  1184.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1185.         If sendProc is nil, the default sendProc is used.
  1186.     
  1187.         Errors:
  1188.             badComponentInstance    invalid scripting component instance
  1189.             errOSASystemError
  1190.     */
  1191. extern pascal OSAError OSAGetSendProc(ComponentInstance scriptingComponent, OSASendUPP *sendProc, long *refCon)
  1192.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0402, 0x7000, 0xA82A);
  1193. /*
  1194.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1195.     
  1196.         Errors:
  1197.             badComponentInstance    invalid scripting component instance
  1198.             errOSASystemError
  1199.     */
  1200. extern pascal OSAError OSASetCreateProc(ComponentInstance scriptingComponent, OSACreateAppleEventUPP createProc, long refCon)
  1201.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0403, 0x7000, 0xA82A);
  1202. /*
  1203.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1204.         If createProc is nil, the default createProc is used.
  1205.     
  1206.         Errors:
  1207.             badComponentInstance    invalid scripting component instance
  1208.             errOSASystemError
  1209.     */
  1210. extern pascal OSAError OSAGetCreateProc(ComponentInstance scriptingComponent, OSACreateAppleEventUPP *createProc, long *refCon)
  1211.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0404, 0x7000, 0xA82A);
  1212. /*
  1213.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1214.     
  1215.         Errors:
  1216.             badComponentInstance    invalid scripting component instance
  1217.             errOSASystemError
  1218.     */
  1219. extern pascal OSAError OSASetDefaultTarget(ComponentInstance scriptingComponent, const AEAddressDesc *target)
  1220.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0405, 0x7000, 0xA82A);
  1221. /*
  1222.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1223.         This routine sets the default target application for AE sending.
  1224.         It also establishes the default target from which terminologies come.
  1225.         It is effectively like having an AppleScript "tell" statement around
  1226.         the entire program.  If this routine is not called, or if the target 
  1227.         is a null AEDesc, then the current application is the default target.
  1228.     
  1229.         Errors:
  1230.             badComponentInstance    invalid scripting component instance
  1231.             errOSASystemError
  1232.     */
  1233. /**************************************************************************
  1234.     OSA Optional Recording Interface
  1235. **************************************************************************
  1236.     Scripting components that support the Recording interface have the 
  1237.     kOSASupportsRecording bit set in it's ComponentDescription.
  1238. **************************************************************************/
  1239. extern pascal OSAError OSAStartRecording(ComponentInstance scriptingComponent, OSAID *compiledScriptToModifyID)
  1240.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0501, 0x7000, 0xA82A);
  1241. /*
  1242.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1243.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1244.         new script ID is created and returned.  If the current application has
  1245.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1246.         are sent to the application containing the text of each AppleEvent 
  1247.         recorded.
  1248.     
  1249.         Errors:
  1250.             badComponentInstance    invalid scripting component instance
  1251.             errOSASystemError
  1252.             errOSAInvalidID
  1253.             errOSARecordingIsAlreadyOn
  1254.     */
  1255. extern pascal OSAError OSAStopRecording(ComponentInstance scriptingComponent, OSAID compiledScriptID)
  1256.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0502, 0x7000, 0xA82A);
  1257. /*
  1258.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1259.         If compiledScriptID is not being recorded into or recording is not
  1260.         currently on, no error is returned.
  1261.     
  1262.         Errors:
  1263.             badComponentInstance    invalid scripting component instance
  1264.             errOSASystemError
  1265.             errOSAInvalidID
  1266.     */
  1267. /**************************************************************************
  1268.     OSA Optional Convenience Interface
  1269. **************************************************************************
  1270.     Scripting components that support the Convenience interface have the 
  1271.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1272. **************************************************************************/
  1273. extern pascal OSAError OSALoadExecute(ComponentInstance scriptingComponent, const AEDesc *scriptData, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1274.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0601, 0x7000, 0xA82A);
  1275. /*
  1276.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1277.         This routine is effectively equivalent to calling OSALoad followed by
  1278.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1279.         resulting value ID is retained.
  1280.     
  1281.         Errors:
  1282.             badComponentInstance        invalid scripting component instance
  1283.             errOSASystemError
  1284.             errOSABadStorageType:        scriptData not for this scripting component
  1285.             errOSACorruptData:            data seems to be corrupt
  1286.             errOSADataFormatObsolete    script data format is no longer supported
  1287.             errOSADataFormatTooNew        script data format is from a newer version
  1288.             errOSAInvalidID
  1289.             errOSAScriptError:            the executing script got an error
  1290.     
  1291.         ModeFlags:
  1292.             kOSAModeNeverInteract
  1293.             kOSAModeCanInteract
  1294.             kOSAModeAlwaysInteract
  1295.             kOSAModeCantSwitchLayer
  1296.             kOSAModeDontReconnect
  1297.             kOSAModeDoRecord
  1298.     */
  1299. extern pascal OSAError OSACompileExecute(ComponentInstance scriptingComponent, const AEDesc *sourceData, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1300.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0602, 0x7000, 0xA82A);
  1301. /*
  1302.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1303.         This routine is effectively equivalent to calling OSACompile followed by
  1304.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1305.         resulting value ID is retained.
  1306.     
  1307.         Errors:
  1308.             badComponentInstance    invalid scripting component instance
  1309.             errOSASystemError
  1310.             errAECoercionFail:        sourceData is not compilable
  1311.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1312.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1313.                                     valid on input
  1314.             errOSAScriptError:        the executing script got an error
  1315.     
  1316.         ModeFlags:
  1317.             kOSAModeNeverInteract
  1318.             kOSAModeCanInteract
  1319.             kOSAModeAlwaysInteract
  1320.             kOSAModeCantSwitchLayer
  1321.             kOSAModeDontReconnect
  1322.             kOSAModeDoRecord
  1323.     */
  1324. extern pascal OSAError OSADoScript(ComponentInstance scriptingComponent, const AEDesc *sourceData, OSAID contextID, DescType desiredType, long modeFlags, AEDesc *resultingText)
  1325.  FIVEWORDINLINE(0x2F3C, 0x14, 0x0603, 0x7000, 0xA82A);
  1326. /*
  1327.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1328.         This routine is effectively equivalent to calling OSACompile followed by
  1329.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1330.         and the resulting value are is disposed.  Only the resultingText
  1331.         descriptor is retained.  If a script error occur during processing, the 
  1332.         resultingText gets the error message of the error, and errOSAScriptError
  1333.         is returned.  OSAScriptError may still be used to extract more 
  1334.         information about the particular error.
  1335.     
  1336.         Errors:
  1337.             badComponentInstance    invalid scripting component instance
  1338.             errOSASystemError
  1339.             errAECoercionFail:        sourceData is not compilable or 
  1340.                                     desiredType not supported by scripting component
  1341.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1342.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1343.                                     valid on input
  1344.             errOSAScriptError:        the executing script got an error
  1345.     
  1346.         ModeFlags:
  1347.             kOSAModeNeverInteract
  1348.             kOSAModeCanInteract
  1349.             kOSAModeAlwaysInteract
  1350.             kOSAModeCantSwitchLayer
  1351.             kOSAModeDontReconnect
  1352.             kOSAModeDoRecord
  1353.             kOSAModeDisplayForHumans
  1354.     */
  1355. /**************************************************************************
  1356.     OSA Optional Dialects Interface
  1357. **************************************************************************
  1358.     Scripting components that support the Dialects interface have the 
  1359.     kOSASupportsDialects bit set in it's ComponentDescription.
  1360. **************************************************************************/
  1361. /*
  1362.     These calls allows an scripting component that supports different dialects
  1363.     to dynamically switch between those dialects.  Although this interface is
  1364.     specified, the particular dialect codes are scripting component dependent.
  1365. */
  1366. extern pascal OSAError OSASetCurrentDialect(ComponentInstance scriptingComponent, short dialectCode)
  1367.  FIVEWORDINLINE(0x2F3C, 0x2, 0x0701, 0x7000, 0xA82A);
  1368. /*
  1369.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1370.     
  1371.         Errors:
  1372.             badComponentInstance    invalid scripting component instance
  1373.             errOSASystemError
  1374.             errOSANoSuchDialect:    invalid dialectCode
  1375.     */
  1376. extern pascal OSAError OSAGetCurrentDialect(ComponentInstance scriptingComponent, short *resultingDialectCode)
  1377.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0702, 0x7000, 0xA82A);
  1378. /*
  1379.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1380.     
  1381.         Errors:
  1382.             badComponentInstance    invalid scripting component instance
  1383.             errOSASystemError
  1384.     */
  1385. extern pascal OSAError OSAAvailableDialects(ComponentInstance scriptingComponent, AEDesc *resultingDialectInfoList)
  1386.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0703, 0x7000, 0xA82A);
  1387. /*
  1388.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1389.         This call return an AEList containing information about each of the
  1390.         currently available dialects of a scripting component.  Each item
  1391.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1392.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1393.         keyOSADialectScriptCode.
  1394.     
  1395.         Errors:
  1396.             badComponentInstance    invalid scripting component instance
  1397.             errOSASystemError
  1398.     */
  1399. extern pascal OSAError OSAGetDialectInfo(ComponentInstance scriptingComponent, short dialectCode, OSType selector, AEDesc *resultingDialectInfo)
  1400.  FIVEWORDINLINE(0x2F3C, 0xA, 0x0704, 0x7000, 0xA82A);
  1401. /*
  1402.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1403.         This call gives information about the specified dialect of a scripting
  1404.         component. It returns an AEDesc whose type depends on the selector 
  1405.         specified. Available selectors are the same as the field keys for a
  1406.         dialect info record. The type of AEDesc returned is the same as the 
  1407.         type of the field that has same key as the selector.
  1408.     
  1409.         Errors:
  1410.             badComponentInstance    invalid scripting component instance
  1411.             errOSASystemError
  1412.              errOSABadSelector
  1413.             errOSANoSuchDialect:    invalid dialectCode
  1414.     */
  1415. extern pascal OSAError OSAAvailableDialectCodeList(ComponentInstance scriptingComponent, AEDesc *resultingDialectCodeList)
  1416.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0705, 0x7000, 0xA82A);
  1417. /*
  1418.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1419.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1420.         and  OSAGetDialectInfo to get information on dialects.
  1421.         This call return an AEList containing dialect code for each of the
  1422.         currently available dialects of a scripting component. Each dialect
  1423.         code is a short integer of type typeShortInteger.
  1424.     
  1425.         Errors:
  1426.             badComponentInstance    invalid scripting component instance
  1427.             errOSASystemError
  1428.  
  1429.         Type of a dialect info record containing at least keyOSADialectName
  1430.         and keyOSADialectCode fields.
  1431.  
  1432.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1433.  
  1434.         Field of a typeOSADialectInfo record of typeChar.
  1435.         Field of a typeOSADialectInfo record of typeShortInteger.
  1436.         Field of a typeOSADialectInfo record of typeShortInteger.
  1437.         Field of a typeOSADialectInfo record of typeShortInteger.
  1438.     */
  1439. /**************************************************************************
  1440.     OSA Optional Event Handling Interface
  1441. **************************************************************************
  1442.     Scripting components that support the Event Handling interface have the 
  1443.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1444. **************************************************************************/
  1445. extern pascal OSAError OSASetResumeDispatchProc(ComponentInstance scriptingComponent, AEEventHandlerUPP resumeDispatchProc, long refCon)
  1446.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0801, 0x7000, 0xA82A);
  1447. /*
  1448.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1449.         This function is used to set the ResumeDispatchProc that will be used
  1450.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1451.         found in the context, or the context event hander "continues" control
  1452.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1453.         may also be passed to this routine indicating that the handler registered
  1454.         in the application with AEInstallEventHandler should be used, or no
  1455.         dispatch should occur, respectively.
  1456.     
  1457.         Errors:
  1458.             badComponentInstance    invalid scripting component instance
  1459.             errOSASystemError
  1460.     */
  1461.  
  1462. enum {
  1463.     kOSAUseStandardDispatch        = kAEUseStandardDispatch
  1464. };
  1465.  
  1466. /*
  1467.         Special ResumeDispatchProc constant which may be passed to 
  1468.         OSASetResumeDispatchProc indicating that the handler registered
  1469.         in the application with AEInstallEventHandler should be used.
  1470.         
  1471.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1472.                 doesn't allow pointer types to be assigned to an enum.  All
  1473.                 constants must be assigned as enums to translate properly to
  1474.                 Pascal.
  1475.     */
  1476. enum {
  1477.     kOSANoDispatch                = kAENoDispatch
  1478. };
  1479.  
  1480. /*
  1481.         Special ResumeDispatchProc constant which may be passed to 
  1482.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1483.         
  1484.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1485.                 doesn't allow pointer types to be assigned to an enum.  All
  1486.                 constants must be assigned as enums to translate properly to
  1487.                 Pascal.
  1488.     */
  1489. enum {
  1490.     kOSADontUsePhac                = 0x0001
  1491. };
  1492.  
  1493. /*
  1494.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1495.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1496.         This causes the standard dispatch to be performed, except the phac
  1497.         handler is not called.  This is useful during tinkerability, when
  1498.         the phac handler is used to lookup a context associated with an event's 
  1499.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1500.         bypass the phac handler would result in an infinite loop.
  1501.     */
  1502. extern pascal OSAError OSAGetResumeDispatchProc(ComponentInstance scriptingComponent, AEEventHandlerUPP *resumeDispatchProc, long *refCon)
  1503.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0802, 0x7000, 0xA82A);
  1504. /*
  1505.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1506.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1507.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1508.     
  1509.         Errors:
  1510.             badComponentInstance    invalid scripting component instance
  1511.             errOSASystemError
  1512.     */
  1513. extern pascal OSAError OSAExecuteEvent(ComponentInstance scriptingComponent, const AppleEvent *theAppleEvent, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1514.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0803, 0x7000, 0xA82A);
  1515. /*
  1516.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1517.         This call is similar to OSAExecute except the initial command to
  1518.         execute comes in the form of an AppleEvent.  If the contextID
  1519.         defines any event handlers for that event, they are used to process
  1520.         the event.  If no event handler can be found in the context
  1521.         errAEEventNotHandled is returned.  If an event handler is found and
  1522.         the hander "continues" control onward, the ResumeDispatchProc
  1523.         (registered with OSASetResumeDispatchProc, above) is called given the
  1524.         AppleEvent.  The result is returned as a scriptValueID.
  1525.     
  1526.         Errors:
  1527.             badComponentInstance    invalid scripting component instance
  1528.             errOSASystemError
  1529.             errOSAInvalidID
  1530.             errOSAScriptError:        the executing script got an error
  1531.             errAEEventNotHandled:    no handler for event in contextID
  1532.     
  1533.         ModeFlags:
  1534.             kOSAModeNeverInteract
  1535.             kOSAModeCanInteract
  1536.             kOSAModeAlwaysInteract
  1537.             kOSAModeCantSwitchLayer
  1538.             kOSAModeDontReconnect
  1539.             kOSAModeDoRecord
  1540.     */
  1541. extern pascal OSAError OSADoEvent(ComponentInstance scriptingComponent, const AppleEvent *theAppleEvent, OSAID contextID, long modeFlags, AppleEvent *reply)
  1542.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0804, 0x7000, 0xA82A);
  1543. /*
  1544.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1545.         This call is similar to OSADoScript except the initial command to
  1546.         execute comes in the form of an AppleEvent, and the result is an 
  1547.         AppleEvent reply record.  If the contextID defines any event handlers
  1548.         for that event, they are used to process the event.  If no event handler
  1549.         can be found in the context errAEEventNotHandled is returned.  If an
  1550.         event handler is found and the hander "continues" control onward, the
  1551.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1552.         called given the AppleEvent.  The result is returned in the form of an
  1553.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1554.         if the ResumeDispatchProc returns a reply event indicating an error,
  1555.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1556.         should never return errOSAScriptError).  Any error result returned by
  1557.         the ResumeDispatchProc will be returned by OSADoEvent.
  1558.     
  1559.         Errors:
  1560.             badComponentInstance    invalid scripting component instance
  1561.             errOSASystemError
  1562.             errOSAInvalidID
  1563.             errAEEventNotHandled:    no handler for event in contextID
  1564.     
  1565.         ModeFlags:
  1566.             kOSAModeNeverInteract
  1567.             kOSAModeCanInteract
  1568.             kOSAModeAlwaysInteract
  1569.             kOSAModeCantSwitchLayer
  1570.             kOSAModeDontReconnect
  1571.             kOSAModeDoRecord
  1572.     */
  1573. extern pascal OSAError OSAMakeContext(ComponentInstance scriptingComponent, const AEDesc *contextName, OSAID parentContext, OSAID *resultingContextID)
  1574.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0805, 0x7000, 0xA82A);
  1575. /*
  1576.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1577.         Makes a new empty context which may be passed to OSAExecute or 
  1578.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1579.         created. If parentContext is kOSANullScript then the resulting context
  1580.         does not inherit bindings from any other context.
  1581.     
  1582.         Errors:
  1583.             badComponentInstance    invalid scripting component instance
  1584.             errOSASystemError
  1585.             errOSAInvalidID
  1586.             errAECoercionFail:        contextName is invalid
  1587.     */
  1588.  
  1589. #if PRAGMA_IMPORT_SUPPORTED
  1590. #pragma import off
  1591. #endif
  1592.  
  1593. #if PRAGMA_ALIGN_SUPPORTED
  1594. #pragma options align=reset
  1595. #endif
  1596.  
  1597. #ifdef __cplusplus
  1598. }
  1599. #endif
  1600.  
  1601. #endif /* __OSA__ */
  1602.